package com.lengxf;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class CompleteFutureDemo2 {

    private final static Map<String, Info> map = new ConcurrentHashMap<>();

    public static void main(String[] args) {
        map.put("1", new Info("1"));

        Info info = map.get("1");
        System.out.println(info.toString());
        info.updateName("2");
        System.out.println(info);
        System.out.println(map.get("1").toString());

    }

    public static class Info {
        private String name;

        public void setName(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public Info(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Info{" +
                    "name='" + name + '\'' +
                    '}';
        }

        public Info updateName(String name) {
            this.name = name;
            return this;
        }
    }


}
